Skip to content

structured logging#59

Open
c-cube wants to merge 11 commits intomasterfrom
sc/structured-logging
Open

structured logging#59
c-cube wants to merge 11 commits intomasterfrom
sc/structured-logging

Conversation

@c-cube
Copy link
Copy Markdown
Contributor

@c-cube c-cube commented Apr 21, 2026

  • modifies how loggers work so it's easier to swap them at runtime
  • pass timestamp and a list of key/value pairs
  • normal callsites for logging are unaffected, but it enables us to have richer logging.

@c-cube c-cube force-pushed the sc/structured-logging branch from c2eced1 to 07ed94a Compare April 21, 2026 20:39
@c-cube c-cube force-pushed the sc/structured-logging branch from de9c75f to ba7e6f4 Compare April 28, 2026 14:34
@c-cube c-cube requested a review from rr0gi April 28, 2026 15:37
@c-cube c-cube marked this pull request as ready for review April 29, 2026 18:44
@c-cube c-cube force-pushed the sc/structured-logging branch from ba7e6f4 to c87470a Compare April 30, 2026 13:48
@c-cube
Copy link
Copy Markdown
Contributor Author

c-cube commented Apr 30, 2026

GHA/ocaml-setup is doing weird stuff, but otherwise it's ready for review.

@c-cube
Copy link
Copy Markdown
Contributor Author

c-cube commented May 4, 2026

will merge wed 5/6

Copy link
Copy Markdown
Contributor

@rr0gi rr0gi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't like that it changes the format of default logging
i would suggest having another parameter that keeps old message in default logfmt and uses pairs in rich (in addition to current ~pairs which i understand appends pairs to log message always)

Comment thread httpev.ml Outdated
let do_fork () =
match check_req req with
| `Error err -> Exn.fail "pre fork %s : %s" (show_request req) (Unix.error_message err)
| `Error err -> Exn.fail "pre fork : %s" (show_request req) (Unix.error_message err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^

Comment thread web.ml
let verbose_curl_result nr_http action t h code =
let open Curl in
let b = Buffer.create 10 in
bprintf b "%s #%d %s ⇓%s ⇑%s %s "
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so how will Web request log look like now?

@c-cube
Copy link
Copy Markdown
Contributor Author

c-cube commented May 5, 2026 via email

@c-cube c-cube requested a review from rr0gi May 6, 2026 13:58
@c-cube
Copy link
Copy Markdown
Contributor Author

c-cube commented May 6, 2026

Ok, the web and http logs should be back to (almost) exactly what they were, modulo a bit of punctuation (some ":" added). The logging is more uniform now, and checks what logging backend we use to log accordingly.

@c-cube c-cube force-pushed the sc/structured-logging branch from 06db0f7 to 0a08364 Compare May 6, 2026 14:03
Comment thread web.ml Outdated
Comment thread httpev.ml
Hashtbl.remove c.server.reqs req.id;
if c.server.config.debug then
log #info "finished %s" (show_request req)
log_req `Info req "finished"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i lowkey hoped it is possible to preserve log #info way

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problem is that it's better to push info into key/value pairs, so they're easily queryable, so we can't have a single format string for both cases

Comment thread log.ml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants